Trò chơi Pac-Man

20.564 lượt xem;
1 using UnityEngine;
2 using
System.Collections;
3
4 public
class MusicManager : MonoBehaviour {
5
6     
//-------------------------------------------------------------------
7     
// singleton implementation
8     
private static MusicManager _instance;
9
10     
public static MusicManager instance
11     {
12         
get
13         {
14             
if (_instance == null)
15             {
16                 _instance = GameObject.FindObjectOfType<MusicManager>();
17                 DontDestroyOnLoad(_instance.gameObject);
18             }
19
20             
return _instance;
21         }
22     }
23
24     
void Awake()
25     {
26         
if (_instance == null)
27         {
28             _instance =
this;
29             DontDestroyOnLoad(
this);
30         }
31         
else
32         {
33             
if (this != _instance)
34                 Destroy(gameObject);
35         }
36
37     }
38
39
40
41
42 }


-------------------------------------------------------------------

singleton implementation



Gõ tìm kiếm nhanh...